package com.fortune.service.impl;

import com.fortune.dao.ClientDao;
import com.fortune.dto.in.client.ClientAddDto;
import com.fortune.dto.in.client.ClientEditDto;
import com.fortune.service.ClientService;
import com.fortune.vo.cPriceMgt.CClientList;
import com.fortune.vo.client.Client;
import com.fortune.vo.client.ClientDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClientServiceImpl implements ClientService {

    @Autowired
    private ClientDao clientDao;

    /**
     * 有效客户
     * @return
     */
    @Override
    public List<Client> findEffectiveClient(String did, String duid) {
        List<Client> findEffectiveClient = clientDao.findEffectiveClient(did, duid);
        return findEffectiveClient;
    }

    /**
     * 无效客户
     * @return
     */
    @Override
    public List<Client> findInvalidClient(String did, String duid) {
        List<Client> findInvalidClient = clientDao.findInvalidClient(did, duid);
        return findInvalidClient;
    }

    /**
     * 全部客户
     * @return
     */
    @Override
    public List<Client> findAllClient(String mid,String did) {
        List<Client> findAllClient = clientDao.findAllClient(mid, did);
        return findAllClient;
    }

    /**
     * 根据客户id查询客户详情
     * @param clientId
     * @return
     */
    @Override
    public ClientDetail findClientDetailByClientId(String did, String clientId) {
        ClientDetail findClientDetailByClientId = clientDao.findClientDetailByClientId(did, clientId);
        return findClientDetailByClientId;
    }

    /**
     * 查询历史订单
     * @param clientId
     * @return
     */
    @Override
    public Integer historyOrderNum(String clientId, String did) {
        Integer historyOrderNum = clientDao.historyOrderNum(clientId, did);
        return historyOrderNum;
    }

    /**
     * 添加客户
     * @param clientAddDto
     * @return
     */
    @Override
    public int addClient(ClientAddDto clientAddDto, String id) {
        int addClient = clientDao.addClient(clientAddDto,id);
        return addClient;
    }

    /**
     * 添加客户维护关系
     * @param did
     * @param id
     * @param number
     * @param userId
     * @return
     */
    @Override
    public int addCAccountOther(String did, String id, String number, float returnPeriod, String userId) {
        int addCAccountOther = clientDao.addCAccountOther(did, id, number, returnPeriod, userId);
        return addCAccountOther;
    }

    @Override
    public String findClientId(String principalPhone) {
        return clientDao.findClientId(principalPhone);
    }

    /**
     * 建立客户与经销商的关系
     * @param did
     * @param id
     * @return
     */
    @Override
    public int addDCRelation(String did, String id) {
        int addDCRelation = clientDao.addDCRelation(did,id);
        return addDCRelation;
    }

    /**
     * 修改客户信息
     * @param clientEditDto
     * @return
     */
    @Override
    public int editClient(ClientEditDto clientEditDto, String did) {
        int editClient = clientDao.editClient(clientEditDto, did);
        return editClient;
    }

    /**
     * 查询有效的总条数
     * @param did
     * @return
     */
    @Override
    public int findEffectiveAcount(String did, String duid) {
        int findEffectiveAcount = clientDao.findEffectiveAcount(did, duid);
        return findEffectiveAcount;
    }

    /**
     * 查询无效的总条数
     * @param did
     * @return
     */
    @Override
    public int findInvalidAcount(String did, String duid) {
        int findInvalidAcount = clientDao.findInvalidAcount(did, duid);
        return findInvalidAcount;
    }

    /**
     * 根据厂商id和经销商id查询客户信息
     * @param dealerId
     * @return
     */
    @Override
    public List<CClientList> queryClientList(String dealerId) {
        return clientDao.queryClientList(dealerId);
    }

    /**
     * 验证手机号是否重复添加
     * @param phone
     * @return
     */
    @Override
    public Client verifyPhoneRepeat(String phone) {
        return clientDao.verifyPhoneRepeat(phone);
    }

    /**
     * 客户停用
     * @param clientId
     * @param did
     * @return
     */
    @Override
    public int editClientDisabled(String clientId, String did) {
        return clientDao.editClientDisabled(clientId, did);
    }

    @Override
    public int editClientEnable(String clientId, String did) {
        return clientDao.editClientEnable(clientId, did);
    }


}
